package org.dbpt.performance;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

public class SequenceDictionaryParamGenerator implements ParamGenerator {
	protected List<String> words;
	private int index;

	public List<String> getWords() {
		return words;
	}

	public void setWords(List<String> words) {
		this.words = words;
	}

	@Override
	public void generate(PreparedStatement preparedStatement, int paramIdx)
			throws SQLException {
		String word = words.get(getIndex());
		preparedStatement.setString(paramIdx, word);
	}

	protected synchronized int getIndex() {
		if(index >= words.size()) {
			index = 0;
		}
		return index++;
	}
	
	
}
